console.log("插件工作正常");
modify();

var hostname = window.location.host;


setInterval("modify()", 2000);

console.log("hostname is:"+hostname);
// var replaceText = "烧死TA";	//	圣战日特典
var replaceText = "朕已阅";

function modify(){
	if(hostname == "weibo.com"){
		modifyWeibo();
	}
	else if( hostname == "user.qzone.qq.com"){
		modifyQzone();
	}
	else if(hostname == "www.renren.com"){
		modifyRenRen();
	}
}


function modifyRenRen(){
	var $likeTag = $("a.ilike_icon");
	if($likeTag.length > 0){
		var likeContent = "";
		for(var index = 0; index < $likeTag.length; index++){
			likeContent = $likeTag[index].innerText.replace("赞", replaceText);
			$likeTag[index].innerText = likeContent;
		}
	}
	$likeTag = $("a.ilike_comment");
	if($likeTag.length > 0){
		var likeContent = "";
		for(var index = 0; index < $likeTag.length; index++){
			likeContent = $likeTag[index].innerText.replace("赞", replaceText);
			$likeTag[index].innerText = likeContent;
		}
	}
}


// function modifyWeibo(){
// 	var $likeTag = $("div.WB_handle>a[action-type=feed_list_like]");
// 	if(($likeTag).length > 0){
// 		var likeContent = '';
// 		for(var index = 0; index < $likeTag.length; index++){
// 			$likeTag.attr("title", "");
// 			likeContent = $likeTag[index].innerHTML;
// 			var tempStr = "阅";
// 			if(/(\d+)/.test($likeTag[index].innerText)){
// 				//表示有数字显示
// 				tempStr = tempStr + /\(\d+\)/.match($likeTag[index].innerText)[0];
// 			}
// 			$likeTag[index].innerHTML = likeContent.replace(/<\/em>./, tempStr);
// 		}
// 	}
// }

function modifyWeibo(){
	// var $likeTag = $("div.WB_handle>a[title='赞']");
	// if($likeTag.length > 0){
	// 	$likeTag.attr("title", replaceText);
	// }
	var $likeTag = $("a[title='赞']");
	if($likeTag.length > 0){
		$likeTag.attr("title", replaceText);
		$(".WB_row_line.WB_row_r4.clearfix.S_line2 .W_icon.icon_praised_b:not(.marked_mp)")
			.after("<span>&nbsp;&nbsp;朕已阅</span>")
			.addClass("marked_mp");
	}
}

function modifyQzone(){
	var $likeTag = $(".qz_like_btn_v3:contains('赞')");
	if ($likeTag.length > 0) {
		var allContent = '';
		var strs = null;
		for(var index = 0; index < $likeTag.length; index++){	
			strs = $likeTag[index].innerHTML;
			allContent += strs;
			strs = strs.replace("赞", replaceText);		//圣战日特典
			$likeTag[index].innerHTML = strs;
		}
	}	
}